{template 'common/header'}
<style type="text/css">
.btn-group .active{background-color:#428bca;color:#fff;}
</style>
<ul class="we7-page-tab">
	<li><a href="{php echo $this->createWebUrl('display')}">返回表单列表</a></li>
	<li><a href="{php echo $this->createWebUrl('post', array('id' => $reid))}">编辑{$activity['title']}</a></li>
	<li class="active"><a href="#">记录显示设置</a></li>
	<li><a href="{php echo $this->createWebUrl('manage', array('id' => $reid))}">提交记录</a></li>
	<li><a href="{php echo $this->createWebUrl('staff', array('op' => 'list','reid' => $reid))}">管理客服</a></li>
</ul>
<div class="alert alert-info info">
	<i class="fa fa-info-circle"></i>
	当前表单: {$activity['title']}
</div>
	<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data" onsubmit="return validate(this);">
        <div class="panel panel-success">
            <div class="panel-heading">前台显示用户提交的记录，为已完成状态</div>
            <div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开启</label>
					<div class="col-sm-9 col-xs-12">
					<div class="btn-group" data-toggle="buttons">					  
						<label class="btn btn-default {if $activity['field'] == 1}active{/if}"><input type="radio" name="field" value="1" {if $activity['field'] == 1} checked="checked"{/if} >启用</label>
						<label class="btn btn-default {if $activity['field'] == 0}active{/if}"><input type="radio" name="field" value="0" {if empty($activity) || $activity['field'] == 0} checked="checked"{/if}>关闭</label>
                    </div>
					</div>
				</div>
				{if $reid}
					<div id="fields">
						<div id="fields-tpl">
						    {loop $record $f}
							<?php $fi=$this->get_fields($f,$reid); ?>
                <div class="form-group fields-item">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">显示的字段</label>
                   <div class="col-sm-9 col-xs-4 col-md-3">
							<input type="hidden" name="fields[]" class="form-control" value="{$f}" readonly/>
							<input type="text" class="form-control" value="{$fi['title']}" readonly/>
                    </div>
					<div class="col-sm-9 col-xs-4 col-md-3" style="padding-top:6px">
						<a href="javascript:;" onclick="delhouritem(this);"><i class="fa fa-times-circle" title="删除字段"> </i></a>
					</div>	
                </div>
						    {/loop}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
						<div class="col-sm-9 col-xs-9 col-md-9">
							<a href="javascript:;" id="fields-add" class="btn btn-success"><i class="fa fa-plus-circle"></i> 添加显示的字段</a>
							<div class="help-block">显示顺序按自定义字段设置de排序</div>
						</div>
					</div>
				{/if}
            </div>
        </div>
        <div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
   </form>
	<script type="text/javascript">
		function delhouritem(obj) {
			if($(':text[name="fields[]"]').length == 1) return false;
			$(obj).parent().parent().remove();
			return false;
		}
		$(function(){
			$('#fields-add').click(function(){
				var fields_length = $('#fields .fields-item').length;
				if(fields_length < 3) {
			var html = '<div class="form-group">'+
						'<label class="col-xs-12 col-sm-3 col-md-2 control-label">字段</label>'+
						'<div class="col-xs-12 col-sm-9">'+
						'<select name="fields[]" class="form-control">'+
						'<option value="0">请选择要显示的字段内容</option>'+
						'{loop $ds $fields}'+
						'<option value="{$fields['refid']}">{$fields['title']}</option>'+
						'{/loop}'+
						'</select>'+
						'</div>'+
						'</div>';
								
					$('#fields').append(html);
				}		
			});
		});
	</script>
{template 'common/footer'}